import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import org.junit.Test;

public class MainTest {

	private static final int FILE_MAX = 40;

	private boolean testAnswer(int number) throws FileNotFoundException {
		int len = Integer.toString(number).length();
		String numStr;
		if (len == 1) {
			numStr = "00" + Integer.toString(number);
		} else if (len == 2) {
			numStr = "0" + Integer.toString(number);
		} else {
			numStr = Integer.toString(number);
		}
		String[] args = new String[2];
		args[0] = "data/stacking-" + numStr + ".in";
		Main.main(args);
		@SuppressWarnings("resource")
		Scanner outScanner = new Scanner(new File("answer.txt"));

		@SuppressWarnings("resource")
		Scanner ansScanner = new Scanner(new File("data/stacking-" + numStr + ".ans"));

		while (outScanner.hasNext() && ansScanner.hasNext()) {
			

			if (!outScanner.nextLine().equals(ansScanner.nextLine()))
				return false;
		}
		return outScanner.hasNext() == ansScanner.hasNext();
	}

	@Test
	public void test() throws FileNotFoundException {
		for (int i = 2; i <= FILE_MAX; i++) {
			System.out.println(Integer.toString(i));
			assertTrue(testAnswer(i));
		}
	}

}
